package com.from2112.lib.net;

import com.from2112.lib.net.converter.NetGsonConverterFactory;
import com.from2112.lib.net.okhttpclient.CustomOkhttp;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;

/**
 * Description:
 * User: XC
 * Date: 2018-12-04
 * Time: 16:48
 */
public class NetWork {

    public NetRequest getRequest() {
        return initRequest();
    }

    public NetRequest initRequest() {
        Retrofit.Builder builder = new Retrofit.Builder();
        Retrofit build = builder.client(CustomOkhttp.getClient())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(NetGsonConverterFactory.create())
                .baseUrl(NetHost.getHost())
                .build();
        NetRequest netRequest = build.create(NetRequest.class);
        return netRequest;
    }
}
